//
//  Tab3CV.m
//  OCProject
//
//  Created by 王明钦 on 2018/2/9.
//  Copyright © 2018年 oc. All rights reserved.
//

#import "Tab3CV.h"

static NSString * const cellId = @"CollectionCV";

@interface Tab3CV ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property(nonatomic, strong) UICollectionView *layout;

@property(nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation Tab3CV

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setMainTitle:@"TAB3"];
 
    [self.view addSubview:self.collectionView];
    
    
}

-(UICollectionView *)collectionView{
    if (!_layout) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake(80, 40);
        flowLayout.minimumInteritemSpacing = 10;
        flowLayout.minimumLineSpacing = 20;
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        
        _layout = [[UICollectionView alloc] initWithFrame:CGRectMake(0, BAR_HIGHT, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:flowLayout];
        _layout.backgroundColor = [UIColor whiteColor];
        _layout.delegate = self;
        _layout.dataSource = self;
        [_layout registerNib:[UINib nibWithNibName:cellId bundle:nil] forCellWithReuseIdentifier:cellId];

        
    }
    return _layout;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 3;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 2;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [self.layout dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
//    cell.backgroundColor = [UIColor purpleColor];
    
    return cell;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
